package com.czxy.demo12;

public class Test01 {
    public static void main(String[] args) {

        String[][] all = {
                {"张三","37","89","5"},
                {"李四","95","41","79"},
                {"王五","60","84","29"},
                {"赵六","87","46","86"}
        };
        printMathScore(all);
        getCountMathScore(all);
        getAvgMathScore(all);
        getAvgName(all);
        getAvgCOunt(all);
    }
    public static void printMathScore(String[][] arr){
        for (String[] s : arr) {
            System.out.println(s[2]);
        }
    }
    public static void getCountMathScore(String[][] arr){
        int sum = 0;
        for (String[] s : arr) {
            sum+=Integer.parseInt(s[2]);
        }
        System.out.println("所有同学数学成绩的总和是: "+sum);
    }
    public static void getAvgMathScore(String[][] arr){
        int sum = 0;
        for (String[] s : arr) {
            sum+=Integer.parseInt(s[2]);
        }
        System.out.println("所有同学数学成绩的平均分是: "+sum/arr.length);
    }

    public static void getAvgName(String[][] arr){
        int sum = 0;
        for (String[] s : arr) {
            sum+=Integer.parseInt(s[2]);
        }
        int avg = sum / arr.length;
        System.out.print("数学成绩高过平均分的人有:");
        for (int i = 0; i < arr.length; i++) {
            if (Integer.parseInt(arr[i][2])>avg){
                System.out.print(arr[i][0]+"  ");
            }
        }
        System.out.println();
    }

    public static void getAvgCOunt(String[][] arr){
        int sum = 0;
        for (String[] s : arr) {
            sum+=Integer.parseInt(s[2]);
        }
        int count = 0;
        int avg = sum / arr.length;
        for (int i = 0; i < arr.length; i++) {
            if (Integer.parseInt(arr[i][2])>avg){
                count++;
            }
        }
        System.out.println("数学成绩高过平均分的人数有 :"+count);
    }
}
